package cn.edu.sbs.talent.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

@Configuration
@EnableSwagger2
public class SwaggerConfiguration {
    private ApiInfo apiInfo() {
        return new ApiInfoBuilder()
                // 设置页面标题
                .title("东赵家村管综合信息化平台-后端API接口文档")
                // 设置联系人
                .contact(new Contact("上商-正个八经下乡队",
                        "https://gitee.com/east_zhaojiaguan_village/VillageManagementPlatform",
                        "kiols6@aliyun.com"))
                // 描述
                .description("欢迎访问东赵家村管综合信息化平台接口文档，这里是描述信息")
                // 定义版本号
                .version("0.0.1").build();
    }


    @Bean("权限及角色管理模块")
    public Docket controller1Apis() {
        return new Docket(DocumentationType.SWAGGER_2)
                .groupName("权限及角色管理模块")
                .apiInfo(apiInfo()).select()
                .apis(RequestHandlerSelectors.basePackage("com.ishang.vm.admin.controller"))
                .paths(PathSelectors.any()).build();
    }

    @Bean("办公模块")
    public Docket controller2Apis() {
        return new Docket(DocumentationType.SWAGGER_2)
                .groupName("办公模块")
                .apiInfo(apiInfo()).select()
                .apis(RequestHandlerSelectors.basePackage("com.ishang.vm.office.controller"))
                .paths(PathSelectors.any()).build();
    }
}
